package com.ihrm.system.service.Impl;

import com.ihrm.system.dao.UserRoleDao;
import com.ihrm.system.service.UserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Transactional
public class UserRoleServiceImpl implements UserRoleService {

    @Autowired
    private UserRoleDao userRoleDao;

    @Override
    public void update(String userId, List<String> roleIds) {
        userRoleDao.delByIds(userId);
        Map map = new HashMap();
        map.put("userId",userId);
        map.put("roleIds",roleIds);
        if(roleIds.size() > 0) {
            userRoleDao.insertBatch(map);
        }
    }
}
